package com.wc.alorithm_luogu._模拟.P1010;

import java.util.Scanner;

/**
 * @Author congege
 * @Description [NOIP1998 普及组] 幂次方
 * https://www.luogu.com.cn/problem/P1010
 * @Date Created in 2023/9/15-16:13
 */
public class Main {
    public static void main(String[] args) {
//        int n = 2 * 10000;
//        System.out.println(Integer.toString(n, 2));

        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        scan.close();
        Main main = new Main();
        System.out.println(main.power(n));
    }

    private String[] oneTwo = {"", "2(0)", "2"};

    public String power(int n) {
        if (n <= 2) {
            return oneTwo[n];
        }
        /**
         * 转化为2进制
         */
        String n2radix = Integer.toString(n, 2);

        char[] seats = n2radix.toCharArray();

        int numberLen = seats.length;
        StringBuffer ans = new StringBuffer();
        for (int i = 0; i < numberLen - 2; i++) {
            if (seats[i] == '1') {
                ans.append(2);
                ans.append('(');
                ans.append(power(numberLen - i - 1));
                ans.append(')');
                ans.append('+');
            }
        }


        for (int i = 2; i >= 1; i--) {
            if (seats[numberLen - i] == '1') {
                ans.append(oneTwo[i]);
                ans.append('+');
            }
        }

        /**
         * 删除最后以为加号
         */
        ans.deleteCharAt(ans.length() - 1);
        return ans.toString();
    }
}
